package com.game.message.selfbinary.codec;

import com.game.message.selfbinary.Message;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class PacketEncoder extends MessageToByteEncoder<Message> {

	@Override
	protected void encode(ChannelHandlerContext ctx, Message message, ByteBuf out) throws Exception {
		out.writeBytes(message.encode().getOrignalBuffer());
		ctx.writeAndFlush(out);
		out.retain();
	}

}
